/*
    main.me -- MakeMe for the Multithreaded Portable Runtime (MPR)
 */

Me.load({
    makeme: '>=0.9.0',

    plugins: [ 'installs' ],

    blend: [
        'src/*/*.me',
        'paks/ssl/*.me',
        'test/test.me',
        'doc/doc.me',
    ],

    configure: {
        requires:  [ 'osdep' ],
    },

    customize: [
        /* Optionally load this if present. Feel free to create and customize */
        'custom.me',
    ],

    settings: {
        integrate: true,
        prefixes: 'install-prefixes',
        
        mpr: {
            logging: true,              /* Enable application message logging */
            debug: {
                // logging: true,       /* Enable debug logging (assert) enabled by default in debug builds */
            }
            oslog: false,               /* Write to O/S log file */
            threadStack: 0,             /* Use the system default stack size */
            alloc: {
                // quota: 204800,       /* Amount of memory to allocate before a GC */
                // cache: 0,            /* Amount of memory to buffer for fast allocations */
                // check: false,        /* Memory debug */
            },
            ssl: {
                cache: 512,             /* Set the session cache size (items) */
                logLevel: 3             /* Starting logging level for SSL messages */
                renegotiate: true,      /* Enable/Disable SSL renegotiation (defaults to true) */
                ticket: true,           /* Enable session resumption via ticketing - client side session caching */
                timeout: 86400,         /* Session and ticketing duration in seconds */
            },
        },
        tune: 'size',
    },

    usage: {
        assert: 'Enable program assertions',
    },

    targets: {
        libmpr: {
            type: 'lib',
            depends: [ 'osdep', 'ssl' ],
            headers: [ 'src/*.h' ],
            sources: [ 'src/*.c' ],
            exclude: [ /manager.c/ ],
        },

        package: {
            depends: ['packagePak'],
        },

        packageSource: { },

        projects: {
            action: `genProjects('')`,
        },

        mine: {
            action: `genProjects('', 'mine', Config.OS + '-' + Config.CPU)`,
        },
    },

    manifest: {
        packages: {
            pak: {
                inherit:    'package-manifest',
                prefixes:   [ 'src'],
                formats:    [ 'tar' ],
                sets:       [ 'pak' ],
            },
        },
        sets: { 
            pak: [
                {   
                    from:       'src/dist.me', 
                    to:         '${src}/dist/mpr.me',

                },{
                    from:       'src/mpr.h',
                    to:         '${src}/dist/mpr.h',

                },{
                    from: [
                                'src/mem.c', 
                                'src/mpr.c', 
                                'src/*.c'
                    ],
                    to:        '${src}/dist/mprLib.c',
                    append:    true,
                    header:    '/*\n * ${settings.title} Library Source \n*/\n\n#include \"mpr.h\"',
                    divider:   true,
                    filter:    /^#inc.*mpr.*$/mg, 

                },{
                    from:       ['doc/api/mpr.html', 'doc/api/mpr.tags', 'doc/api/mpr.dtags'],
                    to:         '${src}/doc/api/',
                    relative:   'doc/api',

                },{
                    from:       'doc/contents/man/*.1',
                    to:         '${src}/doc/contents/man/',
                    relative:   'doc/contents/man',
                },
            ],
        },
	},
})
